#pragma once

class CParticleData
{
public:
	CParticleData() = default;
	~CParticleData();
	void addParticle(const Eigen::Vector3d& vPos);
	void addParticle(const Eigen::Vector3d& vPos, const Eigen::Vector3d& vGravity);

	int getSize() const { return m_x.size(); }
	const double getMass(int i) const { return m_masses[i]; }
	const double getInvMass(int i) const { return m_invMasses[i]; }
	const Eigen::Vector3d& getPosition0(int i) const { return m_x0[i];}
	Eigen::Vector3d& getPosition(int i) { return m_x[i]; }
	Eigen::Vector3d& getLastPosition(int i){ return m_lastX[i]; }
	Eigen::Vector3d& getOldPosition(int i) { return m_oldX[i]; }
	Eigen::Vector3d& getVelocity(int i) { return m_v[i]; }
	Eigen::Vector3d& getAcceleration(int i) { return m_a[i]; }
	void setPosition(int i, Eigen::Vector3d vPos) { m_x[i] = vPos; }
	void setMass(int i, double vMass);

private:
	// If the mass is zero, the particle is static
	std::vector<double> m_masses;
	std::vector<double> m_invMasses;

	// Dynamic state
	std::vector<Eigen::Vector3d> m_x0;
	std::vector<Eigen::Vector3d> m_x;
	std::vector<Eigen::Vector3d> m_v;
	std::vector<Eigen::Vector3d> m_a;
	std::vector<Eigen::Vector3d> m_oldX;
	std::vector<Eigen::Vector3d> m_lastX;
};